import type { Card } from '../types';
import ApiConfig from './config'

// 基础URL（已通过vite.config.ts配置代理）
const BASE_URL = '/api/cards';

// 获取所有卡片
export const getAllCards = async (tabId: string) => {
  return ApiConfig.get<Card[]>(`${BASE_URL}?tabId=${tabId}`)
}

export const createCard = async (data: Omit<Card, 'id'>) => {
  return ApiConfig.post<Omit<Card, 'id'>, Card>(BASE_URL, data)
}

export const updateCard = async (id: string, data: Partial<Card>) => {
  return ApiConfig.put<Partial<Card>, Card>(`${BASE_URL}/${id}`, data)
}

export const deleteCard = async (id: string) => {
  return ApiConfig.delete<void, void>(`${BASE_URL}/${id}`)
}
